
import com.Redis.Utils.JedisUtil;
import com.Redis.Utils.MessageUtil;
import com.Redis.Utils.RedisPool;
import com.Redis.Utils.SerialoizebleUtilbak;

import junit.framework.TestCase;
import redis.clients.jedis.Jedis;
public class PubSubDemo {

	        // 替换成你的reids地址和端口
//	        String redisIp = "127.0.0.1";
//	        int reidsPort = 6379;
//	        JedisPool jedisPool = new JedisPool(new JedisPoolConfig(), redisIp, reidsPort);
//	        System.out.println(String.format("redis pool is starting, redis ip %s, redis port %d", redisIp, reidsPort));

//	        SubThread subThread = new SubThread(jedisPool);
//	        subThread.start();
//
//	        Publisher publisher = new Publisher(jedisPool);
//	        publisher.start();
		 
		 public static byte[] rediskey = "key".getBytes();
		    public static byte[] dstkey = "dstkey".getBytes();
		    public static long time=0;
		    public static void main(String args[]){
		        Jedis jedis = RedisPool.getJedis();
		        int i = 0;
		        while (true) {
		            try {
		                byte[] bytes = JedisUtil.brpoplpush(rediskey, dstkey, 0);
		                MessageUtil msg = (MessageUtil) SerialoizebleUtilbak.unSerialize(bytes);
		                if (msg != null) {
		                    System.out.println(msg.getReportData().toString());
		                    System.err.println("========i======"+i++);
		                }
		                time=3000;
		                System.out.println(jedis.lrange(rediskey,0,100));
		                System.out.println(jedis.lrange(dstkey,0,100));
		                Thread.sleep(time);
		            } catch (InterruptedException e) {
		                e.printStackTrace();
		            }
		        }
		    }

}
